import { LocationQueryValue } from 'vue-router'
import https from './http'

// 登录
interface Login {
    email: string,
    password: string
}

export const getLogin = (app: Login) => https.post('user/login', app)

// 获取专栏列表
interface user {
    currentPage: number,
    pageSize: number
}
export const app = (params: user) => https.get('columns', { params })

// 进入专栏
interface userid {
    id: LocationQueryValue | LocationQueryValue[],
    currentPage: number,
    pageSize: number
}
export const details = (params: userid) => https.get(`columns/${params.id}/posts?currentPage=${params.currentPage}&pageSize=${params.pageSize}`)

// 获取用户信息
// interface userid {
//     id: LocationQueryValue | LocationQueryValue[],
//     currentPage: number,
//     pageSize: number
// }
export const user = () => https.get('user/current')

// 上传图片
export const upload = (params: any) => https.post('upload', params)

// 新增文章
export const add = (params: any) => https.post('posts', params)

// 删除单个文章
export const deleteList = (params: any) => https.delete(`posts/${params.id}`)